Skip to content

Conversation

@John6666cat
Copy link

PIL.Image.Image doesn't have dim.

See:
https://discuss.huggingface.co/t/invalid-image-format/112175

What does this PR do?

Fixes # (issue)

Before submitting

Who can review?

Anyone in the community is free to review the PR once the tests have passed. Feel free to tag
members/contributors who may be interested in your PR.

@sayakpaul sayakpaul requested a review from yiyixuxu November 1, 2024 03:55
@HuggingFaceDocBuilderDev

The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.

@John6666cat John6666cat closed this Dec 2, 2024
@John6666cat John6666cat reopened this Dec 2, 2024
`bool`:
`True` if the input is a valid image, `False` otherwise.
"""
return isinstance(image, PIL.Image.Image) or isinstance(image, (np.ndarray, torch.Tensor)) and image.ndim in (2, 3)
Copy link
Collaborator

@yiyixuxu yiyixuxu Dec 3, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

but if it is a PIL.Image, isinstance(image, PIL.Image.Image) will evaluate to True and whole thing will just return True without check the dimension , no?
can you show an example that this fails?

isinstance(image, PIL.Image.Image) or isinstance(image, (np.ndarray, torch.Tensor)) and image.ndim in (2, 3)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's true... I tried it locally and you were right.
I seem to have misunderstood the cause and made a false assumption. I will withdraw the PR. I apologize.

@John6666cat John6666cat closed this Dec 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants